import {findById,show} from "../service/address"
export default {
    namespaced: true,
    state:{
        dialogFormVisible: false,
        disableds: false,
        addressConsignee:'',
        addressPhone:'',
        addressProvince:'',
        addressCity:'',
        addressDistrict:'',
        addressStreet:'',
        addressDetail:'',
        addressIsDefault:'',
        address: {},
        addressList:[]
    },
    mutations:{
        setDialogFormVisible(state,dialogFormVisible){
            state.dialogFormVisible = dialogFormVisible;
        },
        setDisableds(state,disableds){
            state.disableds = disableds;
        },
        setAddressConsignee(state,addressConsignee){
            state.addressConsignee = addressConsignee;
        },
        setAddressPhone(state,addressPhone){
            state.addressPhone = addressPhone;
        },
        setAddressProvince(state,addressProvince){
            state.addressProvince = addressProvince;
        },
        setAddressCity(state,addressCity){
            state.addressCity = addressCity;
        },
        setAddressDistrict(state,addressDistrict){
            state.addressDistrict = addressDistrict;
        },
        setAddressStreet(state,addressStreet){
            state.addressStreet = addressStreet;
        },
        setAddressDetail(state,addressDetail){
            state.addressDetail = addressDetail;
        },
        setAddressIsDefault(state,addressIsDefault){
            state.addressIsDefault = addressIsDefault;
        },
        setAddress(state,address){
            state.address = address;
        },
        setAddressList(state,addressList){
            state.addressList = addressList;
        }
    },
    actions: {
        async findById(context,addressId){
            let response = await findById(addressId);
            context.commit("setAddress", response.data)
        },
        async show(context,userId){
            // console.log("userId")
            let response = await show(userId);
            // console.log(response)
            context.commit("setAddressList", response.data)
        }
    }
}